<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function add(n1,n2){
            n1=n1||0;  //如果n1转换成boolean类型为空，则返回0，否则返回n1
            n2=n2||0;
            return n1+n2;
        }
        console.log(add());  //0
        console.log(add(1)); //1
        console.log(add(1,2));  //3
    </script>
</body>
</html>